package core.september.cloudbadge.panel.server.credentials;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import core.september.cloudbadge.panel.client.credentials.credentialService;

@SuppressWarnings("serial")
public class credentialServiceImpl extends RemoteServiceServlet implements credentialService{

	@Override
	public String logInOutUrl(String location) throws IllegalArgumentException {
		
		UserService userService = UserServiceFactory.getUserService();
		User user = userService.getCurrentUser();
		
		return user != null ? userService.createLogoutURL(location) :  userService.createLoginURL(location);
		
	}

	@Override
	public String logInOutLabel() {
		UserService userService = UserServiceFactory.getUserService();
		User user = userService.getCurrentUser();
		
		return user != null ? "Logout" :  "Login";
	}

}
